package com.month.order.feign.fallback;

import com.month.order.feign.ProductFeignClient;
import com.month.product.bean.Product;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * 兜底回调--远程调用失败时的回调
 */
@Component
public class ProductFeignClientFallback implements ProductFeignClient {
    @Override
    public Product getProductById(Long id) {
        System.out.println("调用商品服务失败");
        Product product = new Product();
        product.setName("未知商品");
        product.setPrice(new BigDecimal(0));
        product.setId(id);
        product.setPurchaseNum(0);
        return product;
    }
}
